-
-
Notifications
You must be signed in to change notification settings - Fork 32.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Optional persistence in generic_thermostat #10636
Optional persistence in generic_thermostat #10636
Conversation
if self._persistence in [ATTR_BOTH, CONF_TARGET_TEMP]: | ||
self._target_temp=state.attributes[ATTR_TEMPERATURE] | ||
if (self._persistence in [ATTR_BOTH, ATTR_OPERATION_MODE] and | ||
state.attributes[ATTR_OPERATION_MODE] == STATE_OFF): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
visually indented line with same indent as next logical line
if not state: | ||
return | ||
if self._persistence in [ATTR_BOTH, CONF_TARGET_TEMP]: | ||
self._target_temp=state.attributes[ATTR_TEMPERATURE] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
missing whitespace around operator
@@ -213,6 +222,19 @@ def _async_sensor_changed(self, entity_id, old_state, new_state): | |||
self._async_update_temp(new_state) | |||
self._async_control_heating() | |||
yield from self.async_update_ha_state() | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
blank line contains whitespace
|
||
ATTR_NONE = 'none' | ||
ATTR_BOTH = 'both' | ||
ATTR_OPERATION_MODE = 'operation_mode' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is available in homeassistant.components.climate
Fix ATTR_OPERATION_MODE from homeassistant.components.climate
}}) | ||
|
||
state = hass.states.get('climate.test_thermostat') | ||
assert(state.attributes[ATTR_TEMPERATURE] == 20) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
undefined name 'ATTR_TEMPERATURE'
State('climate.test_thermostat', '0', {'operation_mode': STATE_OFF}), | ||
)) | ||
|
||
hass.state = CoreState.starting |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
undefined name 'CoreState'
"""Ensure states are restored on startup.""" | ||
mock_restore_cache(hass, ( | ||
State('climate.test_thermostat', '0', {ATTR_TEMPERATURE: "20"}), | ||
State('climate.test_thermostat', '0', {'operation_mode': STATE_OFF}), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
undefined name 'State'
def test_restore_state(hass): | ||
"""Ensure states are restored on startup.""" | ||
mock_restore_cache(hass, ( | ||
State('climate.test_thermostat', '0', {ATTR_TEMPERATURE: "20"}), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
undefined name 'State'
undefined name 'ATTR_TEMPERATURE'
@asyncio.coroutine | ||
def test_restore_state(hass): | ||
"""Ensure states are restored on startup.""" | ||
mock_restore_cache(hass, ( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
undefined name 'mock_restore_cache'
}}) | ||
|
||
state = hass.states.get('climate.test_thermostat') | ||
assert(state.attributes[ATTR_TEMPERATURE] == 20) | ||
assert(state.attributes['operation_mode'] == STATE_OFF) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
no newline at end of file
@@ -226,6 +234,19 @@ def _async_sensor_changed(self, entity_id, old_state, new_state): | |||
self._async_control_heating() | |||
yield from self.async_update_ha_state() | |||
|
|||
@asyncio.coroutine |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
redefinition of unused 'async_added_to_hass' from line 129
Sorry, I think I pushed my PR literally a minute before you pushed yours. If you want, you can certainly rebase on top of the current dev branch - since my PR doesn't restore the operation mode, it would actually add functionality. However, I don't think that this should be configurable. If a user doesn't want the target temperature to be restored on startup, he / she can set the |
My patch work even if target_temperature is set: if there are no prevous states temperature is set from configuration. |
}}) | ||
|
||
state = hass.states.get('climate.test_thermostat') | ||
assert(state.attributes[ATTR_TEMPERATURE] == 20) | ||
assert(state.attributes['operation_mode'] == STATE_OFF) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
blank line at end of file
blank line contains whitespace
@ziotibia81 Then you should change that. 😉 The usual semantics with initial values being set in the configuration is: Restore the state only if no such value is set. |
I agree with @tinloaf, I don't think it should be configurable |
Ok, but we have to restore also 'operation mode' (configurabile if restore or not, or with initial value). Before my patch at restat the state is always auto. So if user want turn off thermostat and be sure that sta off at restart he have to cange setpoint. Is more confortable to change state in off. |
Yes, I agree, we should also restore the operation mode. And if you want to do it 100 percent, you could add an optional |
Ok! I will work on it tomorrow or Monday. |
Outdated by #10690 |
Description:
Generic thermostat can, optionally, hold target_temp and state if changed in UI
Pull request in home-assistant.github.io with documentation (if applicable): home-assistant/home-assistant.io#4003
Example entry for
configuration.yaml
(if applicable):Checklist:
If user exposed functionality or configuration variables are added/changed:
If the code communicates with devices, web services, or third-party tools:
tox
run successfully. Your PR cannot be merged unless tests pass